package com.hunttown.mes.rpc.domain.enums.lbs;

import java.util.HashMap;
import java.util.Map;

/**
 * 日志类型：1注册/2鉴权/3离线
 * created by wangjunfu on 2022/01/18
 */
public enum RegisterLogTypeEnum {
    REGISTER(1, "注册"),
    AUTHOR(2, "鉴权"),
    LEAVE(3, "离线");

    private final int key;
    private final String value;

    RegisterLogTypeEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (RegisterLogTypeEnum temp : RegisterLogTypeEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (RegisterLogTypeEnum temp : RegisterLogTypeEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
